Global Index
HTML5 JS API Index > Web Sockets and Messaging Tutorials & Specs

EventSource

Extends EventTarget.

The EventSource() constructor takes one or two arguments. The first specifies the URL to which to connect. The second specifies the settings, if any, in the form of an EventSourceInit dictionary.

Properties
const unsigned short
CLOSED = 2
The connection is not open, and the user agent is not trying to reconnect. Either there was a fatal error or the close() method was invoked.
const unsigned short
CONNECTING = 0
The connection has not yet been established, or it was closed and the user agent is reconnecting.
const unsigned short
OPEN = 1
The user agent has an open connection and is dispatching events as it receives them.
EventHandleronerror
EventHandleronmessage
EventHandleronopen
unsigned short
readyState
The readyState attribute represents the state of the connection.
DOMString
url
The url attribute must return the absolute URL that resulted from resolving the value that was passed to the constructor.
boolean
withCredentials
The withCredentials attribute must return the value to which it was last initialized. When the object is created, it must be initialized to false.
Constructor
EventSource(DOMString url, optional EventSourceInit eventSourceInitDict)
Operations
void
close()
The close() method must abort any instances of the fetch algorithm started for this EventSource object, and must set the readyState attribute to CLOSED.